package com.haha.helloworld.broadcast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.haha.helloworld.R;

public class BroadActivity2 extends AppCompatActivity {
    private Button btn_click;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_broad2);
        btn_click=(Button)findViewById(R.id.btn_click);
        btn_click.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //发送广播，广播的行为
                Intent intent = new Intent("com.haha.helloworld");
                LocalBroadcastManager.getInstance(BroadActivity2.this).sendBroadcast(intent);            }
        });

    }
}